package com.qkst.website.common.utils;

import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * @description : properties文件处理方法
 * @Author : lihao
 * @Verion : 1.0v
 * @Email : ahlxlihao@163.com
 * @date 2017-02-15
 */
public class PropertiesUtils {
	
	private static final Logger LOG = Logger.getLogger(PropertiesUtils.class);
	
	/**
	 * 读取properties文件
	 * @param path 文件路径, classpath下，path为空
	 * @param fileName  propertie文件名包括后缀 eg abc.properties
	 * @return
	 */
	public static Properties readProperties(String path,String fileName) {
		Properties properties = new Properties();
		try {
			path=path==null?"":path;//判空
			InputStream in = PropertiesUtils.class.getResourceAsStream(path+"/"+fileName);
			// 加载属性列表
			properties.load(in);
			in.close();
		} catch (Exception e) {
			LOG.error("Read properties File "+fileName +" error! ", e);
		}
		return properties;
	}
}
